package com.chixing.config;

import com.chixing.service.MongoDBService;
import com.chixing.service.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 创建定时器
 */
@Component  //1. 注入
public class StaticScheduleTask {
    @Autowired
    private MongoDBService mongoDBService;
    //2. 添加任务
    @Scheduled(cron = "0 0/5 * * * ?") // @Scheduled(fixedRate = 5000) 或者 直接指定间隔时间 5s
    public void configureTasks(){
        System.out.println("执行静态定时任务时间：" + LocalDateTime.now());
        mongoDBService.Mongo2Mysql();

    }


}